package com.ysd.gulimall.product.web;

import com.ysd.gulimall.product.vo.SkuItemVo;
import com.ysd.gulimall.product.service.SkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.concurrent.ExecutionException;

//这里是页面跳转 Controller 比Rest好用
@Controller
public class ItemController {

    @Autowired
    private  SkuInfoService skuInfoService;

    /**
     * 展示当前SKU的详情
     * TODO:当检索功能完成后，实现点击图片和链接跳转查询详情功能  李亚威留 勿删 视频商品详情环境搭建
     */
    @GetMapping("/{skuId}.html")
    public String skuItem(@PathVariable("skuId")  Long skuId, Model model) throws ExecutionException, InterruptedException {
        System.out.println("准备查询" + skuId);
        SkuItemVo vo = skuInfoService.item(skuId);
        model.addAttribute("item",vo);
        return "item";
    }
}
